home *** CD-ROM | disk | FTP | other *** search
/ Aminet 23 / Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso / Aminet / dev / misc / gms_dev.lha / GMSDev / Source / Asm / Blitter / Transparent.s < prev   
Text File  |  1997-12-16  |  7KB  |  276 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Name:      Transparency Example
  3. ;Author:    Paul Manias
  4. ;Copyright: DreamWorld Productions (c) 1996-1997.  Freely distributable.
  5. ;
  6. ;This an example of 3 circles blitted onto a planar screen at different
  7. ;levels of depth.  Move the green circle over the bouncing circles to get
  8. ;an idea of the effects you can achieve with a planar screen.
  9. ;
  10. ;The screen is double buffered and interlaced, just to be a bit different
  11. ;from the other demos.  The circles are removed from the screen using the
  12. ;CLEAR mode and a restore list.
  13.  
  14.     INCDIR    "GMSDev:Includes/"
  15.     INCLUDE    "dpkernel/dpkernel.i"
  16.  
  17.     SECTION    "Demo",CODE
  18.  
  19. ;===========================================================================;
  20. ;                             INITIALISE DEMO
  21. ;===========================================================================;
  22.  
  23.     STARTDPK
  24.  
  25. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  26.     move.l    DPKBase(pc),a6
  27.     lea    ScreenTags(pc),a0
  28.     sub.l    a1,a1
  29.     CALL    Init
  30.     tst.l    d0
  31.     beq.s    .Exit
  32.  
  33.     lea    BOB_List(pc),a0
  34.     move.l    Screen(pc),a1
  35.     CALL    Init
  36.     tst.l    d0
  37.     beq.s    .Exit
  38.  
  39.     move.l    BOB_Circle1(pc),BLC1
  40.     move.l    BOB_Circle2(pc),BLC2
  41.     move.l    BOB_Circle3(pc),BLC3
  42.  
  43.     lea    RestoreTags(pc),a0
  44.     move.l    Screen(pc),a1    ;a1 = Screen.
  45.     CALL    Init    ;>> = Initialise the restore list.
  46.     tst.l    d0    ;d0 = Check for errors.
  47.     beq.s    .Exit    ;>> = Error, exit.
  48.  
  49.     moveq    #ID_JOYDATA,d0    ;Get joydata structure.
  50.     CALL    Get
  51.     move.l    d0,JoyData
  52.     beq.s    .Exit
  53.     move.l    d0,a0    ;Initialise the joydata structure.
  54.     sub.l    a1,a1
  55.     CALL    Init
  56.     tst.l    d0
  57.     beq.s    .Exit
  58.  
  59.     move.l    Screen(pc),a0
  60.     CALL    Display
  61.  
  62.     bsr.s    Main
  63.  
  64. .Exit    move.l    DPKBase(pc),a6
  65.     move.l    JoyData(pc),a0
  66.     CALL    Free
  67.     move.l    Restore(pc),a0
  68.     CALL    Free
  69.     lea    BOB_List(pc),a0
  70.     CALL    Free
  71.     move.l    Screen(pc),a0
  72.     CALL    Free
  73.     MOVEM.L    (SP)+,A0-A6/D1-D7
  74.     moveq    #ERR_OK,d0
  75.     rts
  76.  
  77. ;===========================================================================;
  78. ;                                MAIN LOOP
  79. ;===========================================================================;
  80.  
  81. Main:    moveq    #$00,d7
  82.  
  83.     move.l    SCRBase(pc),a6
  84.     move.l    Screen(pc),a0
  85.     CALL    scrLockVideo
  86.  
  87. .loop    move.l    DPKBase(pc),a6
  88.     move.l    JoyData(pc),a0
  89.     CALL    Query    ;Go get port status.
  90.     move.l    JoyData(pc),a0
  91.     move.l    BOB_Circle1(pc),a1
  92.     move.w    JD_XChange(a0),d0
  93.     add.w    d0,BOB_XCoord(a1)
  94.     move.w    JD_YChange(a0),d0
  95.     add.w    d0,BOB_YCoord(a1)
  96.     move.l    JD_Buttons(a0),d0
  97.     btst    #JB_LMB,d0
  98.     bne.s    .done
  99.  
  100.     move.l    Screen(pc),a0
  101.     move.l    BOB_Circle2(pc),a1
  102.     movem.w    Circle2XV(pc),d0/d1
  103.     bsr.s    MoveBob
  104.     movem.w    d0/d1,Circle2XV
  105.  
  106.     move.l    BOB_Circle3(pc),a1
  107.     movem.w    Circle3XV(pc),d0/d1
  108.     bsr.s    MoveBob
  109.     movem.w    d0/d1,Circle3XV
  110.  
  111. .draw    move.l    Restore(pc),a0
  112.     CALL    Activate    ;Clear all buffered bob's.
  113.  
  114.     move.l    BLTBase(pc),a6
  115.     lea    BOB_List(pc),a1
  116.     CALL    bltDrawBobList    ;Go and draw all circles.
  117.  
  118.     move.l    SCRBase(pc),a6
  119.     CALL    scrWaitAVBL
  120.  
  121.     move.l    Screen(pc),a0
  122.     CALL    scrSwapBuffers
  123.     bra    .loop
  124.  
  125. .done    move.l    SCRBase(pc),a6
  126.     move.l    Screen(pc),a0
  127.     CALL    scrUnlockVideo
  128.     rts
  129.  
  130. ;===========================================================================;
  131. ;                              MOVE A BOB
  132. ;===========================================================================;
  133. ;Function: Moves a bob, bouncing it across the screen.
  134. ;Requires: a1 = Bob to move.
  135. ;       d0 = X Velocity
  136. ;       d1 = Y Velocity
  137. ;Returns:  d0 = New X Velocity.
  138. ;       d1 = New Y Velocity.
  139.  
  140. MoveBob:
  141.     move.l    BOB_Screen(a1),a0
  142.     add.w    d0,BOB_XCoord(a1)
  143.     add.w    d1,BOB_YCoord(a1)
  144.  
  145. .ChkLX    tst.w    BOB_XCoord(a1)
  146.     bgt.s    .ChkTY
  147.     neg.w    BOB_XCoord(a1)
  148.     neg.w    d0
  149.  
  150. .ChkTY    tst.w    BOB_YCoord(a1)
  151.     bgt.s    .ChkRX
  152.     neg.w    BOB_YCoord(a1)
  153.     neg.w    d1
  154.  
  155. .ChkRX    move.l    GS_Bitmap(a0),a2
  156.     move.w    BMP_Width(a2),d2
  157.     sub.w    BOB_Width(a1),d2
  158.     cmp.w    BOB_XCoord(a1),d2
  159.     bgt.s    .ChkBY
  160.     move.w    d2,BOB_XCoord(a1)
  161.     neg.w    d0
  162.  
  163. .ChkBY    move.w    BMP_Height(a2),d2
  164.     sub.w    BOB_Height(a1),d2
  165.     cmp.w    BOB_YCoord(a1),d2
  166.     bgt.s    .done
  167.     move.w    d2,BOB_YCoord(a1)
  168.     neg.w    d1
  169. .done    rts
  170.  
  171. ;===========================================================================;
  172. ;                                  DATA
  173. ;===========================================================================;
  174.  
  175. Circle2XV:    dc.w  3
  176. Circle2YV:    dc.w  2
  177. Circle3XV:    dc.w  -2
  178. Circle3YV:    dc.w  -4
  179.  
  180. JoyData:    dc.l  0
  181.  
  182. ;---------------------------------------------------------------------------;
  183.  
  184. RestoreTags:    dc.l  TAGS_RESTORE
  185. Restore:    dc.l  0
  186.         dc.l  RSA_Entries,3
  187.         dc.l  TAGEND
  188.  
  189. ;---------------------------------------------------------------------------;
  190.  
  191. ScreenTags:    dc.l  TAGS_SCREEN
  192. Screen:        dc.l  0
  193.         dc.l  GSA_Palette,.palette
  194.         dc.l  GSA_Width,640
  195.         dc.l  GSA_Height,256
  196.         dc.l  GSA_Attrib,DBLBUFFER
  197.         dc.l  GSA_ScrMode,HIRES|LACED
  198.         dc.l    GSA_BitmapTags,0
  199.         dc.l    BMA_Planes,3
  200.         dc.l    BMA_Type,PLANAR
  201.         dc.l    TAGEND,0
  202.         dc.l  TAGEND
  203.  
  204. .palette    dc.l  PALETTE,8
  205.         dc.l  $000000,$f00000,$00f000,$f0f000
  206.         dc.l  $0000f0,$f000f0,$00f0f0,$f0f0f0
  207.  
  208. ;---------------------------------------------------------------------------;
  209.  
  210. BOB_List:    dc.l  LIST1
  211. BLC1:        dc.l  TAGS_Circle1
  212. BLC2:        dc.l  TAGS_Circle2
  213. BLC3:        dc.l  TAGS_Circle3
  214.         dc.l  LISTEND
  215.  
  216. TAGS_Circle1:    dc.l  TAGS_BOB
  217. BOB_Circle1:    dc.l  0
  218.         dc.l  BBA_DirectGfx,.frame
  219.         dc.l  BBA_DirectMasks,.frame
  220.         dc.l  BBA_Width,96
  221.         dc.l  BBA_Height,83
  222.         dc.l  BBA_XCoord,100
  223.         dc.l  BBA_YCoord,40
  224.         dc.l  BBA_FPlane,1
  225.         dc.l  BBA_AmtPlanes,1
  226.         dc.l  BBA_Attrib,BBF_CLIP|BBF_MASK|BBF_CLEAR|BBF_CLRNOMASK
  227.         dc.l  TAGEND
  228. .frame        dc.l  CircleGfx
  229.         dc.l  -1
  230.  
  231. TAGS_Circle2:    dc.l  TAGS_BOB
  232. BOB_Circle2:    dc.l  0
  233.         dc.l  BBA_DirectGfx,.frame
  234.         dc.l  BBA_Width,96
  235.         dc.l  BBA_Height,83
  236.         dc.l  BBA_XCoord,278
  237.         dc.l  BBA_YCoord,86
  238.         dc.l  BBA_FPlane,0
  239.         dc.l  BBA_AmtPlanes,1
  240.         dc.l  BBA_Attrib,BBF_CLEAR|BBF_CLRNOMASK|BBF_CLIP
  241.         dc.l  TAGEND
  242. .frame        dc.l  CircleGfx
  243.         dc.l  -1
  244.  
  245. TAGS_Circle3:    dc.l  TAGS_BOB
  246. BOB_Circle3:    dc.l  0
  247.         dc.l  BBA_DirectGfx,.frame
  248.         dc.l  BBA_Width,96
  249.         dc.l  BBA_Height,83
  250.         dc.l  BBA_XCoord,450
  251.         dc.l  BBA_YCoord,150
  252.         dc.l  BBA_FPlane,2
  253.         dc.l  BBA_AmtPlanes,1
  254.         dc.l  BBA_Attrib,BBF_CLEAR|BBF_CLRNOMASK|BBF_CLIP
  255.         dc.l  TAGEND
  256. .frame        dc.l  CircleGfx
  257.         dc.l  -1
  258.  
  259. ;===========================================================================;
  260. ;                         ALL CHIP RAM DATA HERE
  261. ;===========================================================================;
  262.  
  263.     SECTION    "Graphics",DATA_C
  264.  
  265. CircleGfx:    INCBIN "GMS:demos/data/RAW.CircleBob"
  266.  
  267. ;===========================================================================;
  268.  
  269. ProgName:    dc.b  "Transparency Demo",0
  270. ProgAuthor:    dc.b  "Paul Manias",0
  271. ProgDate:    dc.b  "14 December 1997",0
  272. ProgCopyright:    dc.b  "DreamWorld Productions (c) 1996-1997.  Freely distributable.",0
  273. ProgShort:    dc.b  "Planar transparency demonstration.",0
  274.         even
  275.  
  276.